import React, { Component } from "react";
//ref 的回调函数形式
export default class RefCom extends Component {
  //声明单击事件的回调
  show = () => {
    //获取 input 输入的内容
    // console.log(this);
    let v = this.input.value;
    //设置 div 的文本
    this.div.innerHTML = v;
  }

  render() {
    return (
      <div>
        <input type="text" ref={(el) => {this.input = el}} />
        <button onClick={this.show}>发送</button>
        <hr />
        <div
          style={{ width: 400, height: 300, border: "solid 1px #234" }}
          ref={el => this.div = el}
        ></div>
      </div>
    );
  }
}
